from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class editor_gui_fake :
    _call_history = [ ]
    def __init__ ( self ) :
        self . _add_title_label_to_editor = [ ]
        self . _hide_editor = False
        self . _add_mark_to_editor_contents = False
        self . _add_text_to_editor_contents = None
        self . _add_entry_to_editor_contents = False
        self . _delete_entry_from_editor_contents = False
        self . _set_editor_content_entry_string = None
        self . _set_editor_status_string = None
        self . _request_editor_entry_string = False
        self . _remove_all_marks_from_editor_contents = False
        self . _delete_text_from_last_mark_to_end_of_editor_contents = False
        self . _request_is_any_marks_left_in_editor_contents = False
        self . _application_window_reply = None
        self . _gui_create_button_reply = None
        self . _gui_create_entry_reply = None
        self . _gui_create_frame_reply = None
        self . _gui_create_label_reply = None
        self . _gui_create_text_reply = None
        self . _gui_entry_text_reply = None
    def application_window_reply ( self , window ) :
        self . _application_window_reply = window
    def gui_create_button_reply ( self , button ) :
        self . _gui_create_button_reply = button
    def gui_create_entry_reply ( self , entry ) :
        self . _gui_create_entry_reply = entry
    def gui_create_frame_reply ( self , frame ) :
        self . _gui_create_frame_reply = frame
    def gui_create_label_reply ( self , label ) :
        self . _gui_create_label_reply = label
    def gui_create_text_reply ( self , text ) :
        self . _gui_create_text_reply = text
    def gui_entry_text_reply ( self , text ) :
        self . _gui_entry_text_reply = text
    def show_editor ( self ) :
        editor_gui_fake . _call_history += [ editor_gui_fake . show_editor ]
    def hide_editor ( self ) :
        self . _hide_editor = True
    def add_title_label_to_editor ( self , base_name ) :
        self . _add_title_label_to_editor += [ base_name ]
    def add_mark_to_editor_contents ( self ) :
        self . _add_mark_to_editor_contents = True
    def add_text_to_editor_contents ( self , text ) :
        self . _add_text_to_editor_contents = text
    def add_entry_to_editor_contents ( self ) :
        self . _add_entry_to_editor_contents = True
    def delete_entry_from_editor_contents ( self ) :
        self . _delete_entry_from_editor_contents = True
    def set_editor_content_entry_string ( self , txt ) :
        self . _set_editor_content_entry_string = txt
    def set_editor_status_string ( self , txt ) :
        self . _set_editor_status_string = txt
    def request_editor_entry_string ( self ) :
        self . _request_editor_entry_string = True
    def remove_all_marks_from_editor_contents ( self ) :
        self . _remove_all_marks_from_editor_contents = True
    def delete_text_from_last_mark_to_end_of_editor_contents ( self ) :
        self . _delete_text_from_last_mark_to_end_of_editor_contents = True
    def request_is_any_marks_left_in_editor_contents ( self ) :
        self . _request_is_any_marks_left_in_editor_contents = True
        
class arbitrary_module_fake :
    def show_editor ( self ) :
        editor_gui_fake . _call_history += [ arbitrary_module_fake . show_editor ]
    def hide_editor ( self ) :
        pass 
    def application_window_reply ( self , window ) :
        pass
    def gui_create_frame_reply ( self , frame ) :
        pass
    def gui_create_label_reply ( self , label ) :
        pass
    def gui_create_button_reply ( self , button ) :
        pass
    def gui_create_entry_reply ( self , button ) :
        pass
    def gui_entry_text_reply ( self , text ) :
        pass

class mediator_editor_gui_tests : 
    'mediator_editor_gui'
    def __init__ ( self , test ) :
        self . _test = test
        self . _editor_gui = editor_gui_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'editor_gui' 
            , self . _editor_gui 
            , arbitrary_module_fake
            ) )
        editor_gui_fake . _call_history = [ ]
    def test_show_editor ( self ) :
        self . _mediator . show_editor ( )
        self . _test . assume_equal ( editor_gui_fake . _call_history [ : 1 ] , [ editor_gui_fake . show_editor ] )
    def test_hide_editor ( self ) :
        self . _mediator . hide_editor ( )
        self . _test . assume_true ( self . _editor_gui . _hide_editor )
    def test_add_title_label_to_editor ( self ) :
        self . _mediator . add_title_label_to_editor ( 'my base' )
        self . _test . assume_equal ( self . _editor_gui . _add_title_label_to_editor ,  [ 'my base' ] )
    def test_add_mark_to_editor_contents ( self ) :
        self . _mediator . add_mark_to_editor_contents ( )
        self . _test . assume_true ( self . _editor_gui . _add_mark_to_editor_contents )
    def test_add_text_to_editor_contents ( self ) :
        self . _mediator . add_text_to_editor_contents ( 'my text' )
        self . _test . assume_equal ( self . _editor_gui . _add_text_to_editor_contents , 'my text' )
    def test_add_entry_to_editor_contents ( self ) :
        self . _mediator . add_entry_to_editor_contents ( )
        self . _test . assume_true ( self . _editor_gui . _add_entry_to_editor_contents )
    def test_delete_entry_from_editor_contents ( self ) :
        self . _mediator . delete_entry_from_editor_contents ( )
        self . _test . assume_true ( self . _editor_gui . _delete_entry_from_editor_contents )
    def test_set_editor_content_entry_string ( self ) :
        self . _mediator . set_editor_content_entry_string ( 'my string' )
        self . _test . assume_equal ( self . _editor_gui . _set_editor_content_entry_string , 'my string' )
    def test_set_editor_status_string ( self ) :
        self . _mediator . set_editor_status_string ( 'my status' )
        self . _test . assume_equal ( self . _editor_gui . _set_editor_status_string , 'my status' )
    def test_request_editor_entry_string ( self ) :
        self . _mediator . request_editor_entry_string ( )
        self . _test . assume_true ( self . _editor_gui . _request_editor_entry_string )
    def test_remove_all_marks_from_editor_contents ( self ) :
        self . _mediator . remove_all_marks_from_editor_contents ( )
        self . _test . assume_true ( self . _editor_gui . _remove_all_marks_from_editor_contents )
    def test_delete_text_from_last_mark_to_end_of_editor_contents ( self ) :
        self . _mediator . delete_text_from_last_mark_to_end_of_editor_contents ( )
        self . _test . assume_true ( self . _editor_gui . _delete_text_from_last_mark_to_end_of_editor_contents )
    def test_request_is_any_marks_left_in_editor_contents ( self ) :
        self . _mediator . request_is_any_marks_left_in_editor_contents ( )
        self . _test . assume_true ( self . _editor_gui . _request_is_any_marks_left_in_editor_contents )
    def test_application_window_reply ( self ) :
        self . _mediator . application_window_reply ( 'my window' )
        self . _test . assume_equal ( self . _editor_gui . _application_window_reply , 'my window' )
    def test_gui_create_frame_reply ( self ) :
        self . _mediator . gui_create_frame_reply ( 'my frame' )
        self . _test . assume_equal ( self . _editor_gui . _gui_create_frame_reply , 'my frame' )
    def test_gui_create_label_reply ( self ) :
        self . _mediator . gui_create_label_reply ( 'my label' )
        self . _test . assume_equal ( self . _editor_gui . _gui_create_label_reply , 'my label' )
    def test_gui_create_button_reply ( self ) :
        self . _mediator . gui_create_button_reply ( 'my button' )
        self . _test . assume_equal ( self . _editor_gui . _gui_create_button_reply , 'my button' )
    def test_gui_create_entry_reply ( self ) :
        self . _mediator . gui_create_entry_reply ( 'my entry' )
        self . _test . assume_equal ( self . _editor_gui . _gui_create_entry_reply , 'my entry' )
    def test_gui_create_text_reply ( self ) :
        self . _mediator . gui_create_text_reply ( 'my text' )
        self . _test . assume_equal ( self . _editor_gui . _gui_create_text_reply , 'my text' )
    def test_gui_entry_text_reply ( self ) :
        self . _mediator . gui_entry_text_reply ( 'my text' )
        self . _test . assume_equal ( self . _editor_gui . _gui_entry_text_reply , 'my text' )
